Skip to content

fix(client): guard against dotless qualified_name in _setup_instrumentation#6452

Merged
sentrivana merged 2 commits into
getsentry:masterfrom
devteamaegis:fix/valueerror-unhandled-exception-during-sdk-initialization
Jun 1, 2026
Merged

fix(client): guard against dotless qualified_name in _setup_instrumentation#6452
sentrivana merged 2 commits into
getsentry:masterfrom
devteamaegis:fix/valueerror-unhandled-exception-during-sdk-initialization

Conversation

@devteamaegis
Copy link
Copy Markdown
Contributor

What's broken

Passing a functions_to_trace entry whose qualified_name has no dot (e.g. {"qualified_name": "my_function"}) crashes sentry_sdk.init() with an unhandled ValueError. The SDK never initializes and the user gets a hard traceback instead of a warning.

File "sentry_sdk/client.py", line 510, in _setup_instrumentation
    module_name, function_name = function_qualname.rsplit(".", 1)
ValueError: not enough values to unpack (expected 2, got 1)

Why it happens

The rsplit(".", 1) unpacking on line 510 sits before the try/except block that begins on line 512. When qualified_name contains no dot, the list has one element, the two-target unpacking fails, and the ValueError propagates out of __init__ uncaught.

Fix

Added a guard before the rsplit call: if "." is not in function_qualname, log a warning and continue to the next entry. The user gets a clear message to use a fully qualified name (e.g. mymodule.my_function) and SDK init proceeds normally.

Test

test_functions_to_trace_no_dot_does_not_crash — verifies that sentry_sdk.init() with a dot-free qualified_name completes without raising.

Fixes #6451

…tation

When a functions_to_trace entry's qualified_name contains no dot, the
rsplit(".", 1) unpacking at line 510 raised ValueError outside the
surrounding try/except, crashing sentry_sdk.init() entirely. Add an
early check that skips the entry with a warning instead.

Fixes getsentry#6451
@devteamaegis devteamaegis requested a review from a team as a code owner May 31, 2026 22:17
@sentrivana sentrivana enabled auto-merge (squash) June 1, 2026 10:06
@sentrivana sentrivana merged commit 41ff92e into getsentry:master Jun 1, 2026
152 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: ValueError crashes sentry_sdk.init() when functions_to_trace entry has no dot in qualified_name

2 participants